using System;
using System.Collections.Generic;
using System.Text;
using BizTalkCop.Rules.Bases;
using Microsoft.FxCop.Sdk;
using System.Collections;
using System.Xml;

namespace BizTalkCop.Rules
{
    /// <summary>
    /// Dummy rule, used to capture settings for the BizTalk application(s) to check
    /// </summary>
    public class ApplicationConfig : ApplicationRuleBase
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public ApplicationConfig() : base("ApplicationConfig") { }

        /// <summary>
        /// Gets the currently configured BizTalk application name
        /// </summary>
        public string ApplicationName
        {
            get { return GetConfiguredSetting(typeof(ApplicationConfig), Setting.ApplicationName); }
        }

        /// <summary>
        /// Gets the currently configured BizTalk server name
        /// </summary>
        public string BizTalkServer
        {
            get { return GetConfiguredSetting(typeof(ApplicationConfig), Setting.BizTalkServer); }
        }

        /// <summary>
        /// Gets the currently configured BizTalk Management Database name
        /// </summary>
        public string DatabaseName
        {
            get { return GetConfiguredSetting(typeof(ApplicationConfig), Setting.DatabaseName); }
        }

        #region Configured settings

        static ApplicationConfig()
        {
            Dictionary<string, string> defaults = new Dictionary<string, string>();
            defaults.Add(Setting.ApplicationName, Default.ApplicationName);
            defaults.Add(Setting.BizTalkServer, Default.BizTalkServer);
            defaults.Add(Setting.DatabaseName, Default.DatabaseName);
            SetDefaults(typeof(ApplicationConfig), defaults);
        }

        /// <summary>
        /// Default values for settings
        /// </summary>
        public struct Default
        {
            public const string ApplicationName = "BizTalk Application 1";
            public const string BizTalkServer = ".";
            public const string DatabaseName = "BizTalkMgmtDb";
        }

        private struct Setting
        {
            public const string ApplicationName = "ApplicationName";
            public const string BizTalkServer = "BizTalkServer";
            public const string DatabaseName = "DatabaseName";
        }

        #endregion
    }
}
